//
// Created by LiuDongPeng on 2023/11/16.
//

#ifndef FOC_LOWPASS_FILTER_H
#define FOC_LOWPASS_FILTER_H


#include <math.h>
#include <stdbool.h>



typedef struct low_pass_filter
{
	float fc;   // 截止频率
	float dt;   // 采样周期
	float alpha; // 滤波系数

	bool first;
	float lastVal;
} low_pass_filter_t;


int low_pass_filter_init(low_pass_filter_t* filter, float alpha);


float low_pass_filter_work(low_pass_filter_t* filter, float val);


#endif //FOC_LOWPASS_FILTER_H
